//
//  SessionEntity+CoreDataProperties.swift
//  JKTools
//
//  Created by 姜奎 on 2/20/25.
//
//

import Foundation
import CoreData


extension SessionEntity {

    @nonobjc public class func fetchRequest() -> NSFetchRequest<SessionEntity> {
        return NSFetchRequest<SessionEntity>(entityName: "SessionEntity")
    }

    @NSManaged public var sessionId: String
    @NSManaged public var groupText: String
    @NSManaged public var title: String
    @NSManaged public var timestamp: Date

}

extension SessionEntity: Identifiable {
    public var id: NSManagedObjectID { objectID }
}

extension SessionEntity : JKCoreDataModelProtocol {
    public func insertNewSubObject(with entity: NSManagedObject) {

    }

    public static func insertNewObject<T>(with properties: T, into context: NSManagedObjectContext) -> NSManagedObject? {
        guard let properties = properties as? Session else { return nil }
        let group = NSEntityDescription.insertNewObject(forEntityName: "SessionEntity", into: context) as! SessionEntity
        group.sessionId = properties.id
        group.groupText = properties.groupText
        group.timestamp = properties.timestamp
        group.title = properties.title
        return group
    }
}

